home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / program / bgui12.lha / AsmSup / Font.s < prev    next >
Text File  |  1995-04-15  |  11KB  |  262 lines

  1.                 opt     o+,ow-,inconce
  2. *
  3. *       FONT.S
  4. *
  5. *       (C) Copyright 1995 Jaba Development.
  6. *       (C) Copyright 1995 Jan van den Baard.
  7. *           All Rights Reserved.
  8. *
  9. *       This is a small assembly example of BGUI. It is basically the
  10. *       same as the "Font" demo except that this is coded in assembler.
  11. *
  12. *       Assembles OK with Devpac 3.
  13. *
  14.  
  15.                 incdir  'Work:Asm30/'
  16.                 include 'exec/types.i'
  17.                 include 'exec/memory.i'
  18.                 include 'exec/exec_lib.i'
  19.                 include 'dos/dos_lib.i'
  20.                 include 'libraries/bgui.i'
  21.                 include 'libraries/bgui_offsets.i'
  22.                 include 'libraries/bgui_macros.i'
  23.                 include 'libraries/gadtools.i'
  24.  
  25.                 ;
  26.                 ;       Simple shortcut to: jsr _LVOfunc(a6)
  27.                 ;
  28. Call            macro   ; func
  29.                 jsr     _LVO\1(a6)
  30.                 endm
  31.  
  32.                 ;
  33.                 ;       Prints a message to the console.
  34.                 ;
  35. Print           macro
  36.                 move.l  a6,-(sp)
  37.                 move.l  dosbase,a6
  38.                 Call    Output
  39.                 move.l  d0,d1
  40.                 move.l  #\1,d2
  41.                 Call    FPuts
  42.                 move.l  (sp)+,a6
  43.                 endm
  44.  
  45. main:           move.l  (4).w,a6
  46.  
  47.                 ;
  48.                 ;       Open dos.
  49.                 ;
  50.                 lea.l   dosname(pc),a1
  51.                 moveq.l #0,d0
  52.                 Call    OpenLibrary
  53.                 move.l  d0,dosbase
  54.                 beq     bye
  55.  
  56.                 ;
  57.                 ;       Open bgui.
  58.                 ;
  59.                 lea.l   bguiname(pc),a1
  60.                 moveq.l #BGUIVERSION,d0
  61.                 Call    OpenLibrary
  62.                 move.l  d0,bguibase
  63.                 bne.b   bguiok
  64.                 Print   bguierror
  65.                 move.l  dosbase,a1
  66.                 Call    CloseLibrary
  67.                 rts
  68.  
  69. bguiok:         move.l  d0,a6
  70.  
  71.                 ;
  72.                 ;       Create the window object.
  73.                 ;
  74.                 WindowObject
  75.                         ;
  76.                         ;       The PUTC macro can put upto 15 values
  77.                         ;       on the stack. All arguments you pass
  78.                         ;       this macro will get a '#' preceeded
  79.                         ;       so only absolute addresses and constants
  80.                         ;       can be used here. For mixed data the
  81.                         ;       PUTV macro can be used.
  82.                         ;
  83.                         PUTC    WINDOW_Title,wtitle
  84.                         PUTC    WINDOW_ScaleWidth,20
  85.                         PUTC    WINDOW_AutoAspect,1
  86.                         MasterGroup
  87.                                 VGroupObject
  88.                                         Spacing 4
  89.                                         HOffset 4
  90.                                         VOffset 4
  91.                                         StartMember
  92.                                                 InfoObject
  93.                                                         PUTC    INFO_TextFormat,header
  94.                                                         PUTC    INFO_HorizOffset,0
  95.                                                         PUTC    INFO_VertOffset,0
  96.                                                 EndObject
  97.                                         EndMember FixMinHeight
  98.                                         StartMember
  99.                                                 HGroupObject
  100.                                                         PUTC    FRM_Type,FRTYPE_BUTTON
  101.                                                         PUTC    FRM_Recessed,1
  102.                                                         HOffset 4
  103.                                                         VOffset 1
  104.                                                         Spacing 4
  105.                                                         StartMember
  106.                                                                 InfoObject
  107.                                                                         PUTC    INFO_TextFormat,lefttext
  108.                                                                         PUTC    INFO_FixTextWidth,1
  109.                                                                         PUTC    INFO_MinLines,3
  110.                                                                         PUTC    INFO_VertOffset,2
  111.                                                                         PUTC    INFO_HorizOffset,0
  112.                                                                 EndObject
  113.                                                         EndMember
  114.                                                         StartMember
  115.                                                                 InfoObject
  116.                                                                         PUTC    INFO_TextFormat,righttext
  117.                                                                         PUTC    INFO_FixTextWidth,1
  118.                                                                         PUTC    INFO_MinLines,3
  119.                                                                         PUTC    INFO_VertOffset,2
  120.                                                                         PUTC    INFO_HorizOffset,0
  121.                                                                 EndObject
  122.                                                         EndMember
  123.                                                 EndObject
  124.                                         EndMember
  125.                                         ;
  126.                                         ;       With the C macros the layout attributes
  127.                                         ;       must be passed after the EndObject macro.
  128.                                         ;
  129.                                         ;       The assembly macros only allow the layout
  130.                                         ;       attributes after the EndMember macro.
  131.                                         ;
  132.                                         StartMember
  133.                                                 Button wb,0
  134.                                         EndMember FixMinHeight
  135.                                         StartMember
  136.                                                 Button sd,0
  137.                                         EndMember FixMinHeight
  138.                                         StartMember
  139.                                                 Button ss,0
  140.                                         EndMember FixMinHeight
  141.                                         StartMember
  142.                                                 HGroupObject
  143.                                                         StartMember
  144.                                                                 Button save,1
  145.                                                         EndMember
  146.                                                         VarSpace DEFAULT_WEIGHT
  147.                                                         StartMember
  148.                                                                 Button use,1
  149.                                                         EndMember
  150.                                                         VarSpace DEFAULT_WEIGHT
  151.                                                         StartMember
  152.                                                                 Button cancel,1
  153.                                                         EndMember
  154.                                                 EndObject
  155.                                         EndMember FixMinHeight
  156.                                 EndObject
  157.                         EndMaster
  158.                 EndObject
  159.  
  160.                 ;
  161.                 ;       Window OK?
  162.                 ;
  163.                 move.l  d0,WO_Window
  164.                 beq.w   noobj
  165.  
  166.                 ;
  167.                 ;       Open it.
  168.                 ;
  169.                 xWindowOpen WO_Window
  170.                 tst.l   d0
  171.                 beq.w   noopen
  172.  
  173.                 ;
  174.                 ;       Obtain window signal mask.
  175.                 ;
  176.                 DOMETHOD WO_Window,#OM_GET,#WINDOW_SigMask,#winsig
  177.  
  178.                 ;
  179.                 ;       Poll messages.
  180.                 ;
  181.                 move.l  (4).w,a6
  182. msgloop:        move.l  winsig,d0
  183.                 Call    Wait
  184. poll:
  185.                 ;
  186.                 ;       Get messages.
  187.                 ;
  188.                 HandleEvent WO_Window
  189.                 cmp.l   #WMHI_NOMORE,d0
  190.                 beq.b   msgloop
  191.  
  192.                 ;
  193.                 ;       Close gadget pressed?
  194.                 ;
  195.                 cmp.l   #WMHI_CLOSEWINDOW,d0
  196.                 beq.b   noopen
  197.  
  198.                 ;
  199.                 ;       Object with 1 as it's ID selected?
  200.                 ;
  201.                 cmp.l   #1,d0
  202.                 beq.b   noopen
  203.  
  204.                 ;
  205.                 ;       Next please...
  206.                 ;
  207.                 bra.b   poll
  208.  
  209. noopen:
  210.                 ;
  211.                 ;       Dump the window object.
  212.                 ;
  213.                 DOMETHOD WO_Window,#OM_DISPOSE
  214. noobj:
  215.                 ;
  216.                 ;       Close the libraries.
  217.                 ;
  218.                 move.l  (4).w,a6
  219.                 move.l  bguibase,a1
  220.                 Call    CloseLibrary
  221.                 move.l  dosbase,a1
  222.                 Call    CloseLibrary
  223. bye:
  224.                 moveq.l #0,d0
  225.                 rts
  226.  
  227.                 ;
  228.                 ;       Texts used by the code.
  229.                 ;
  230. dosname:        dc.b    'dos.library',0
  231. bguiname:       dc.b    'bgui.library',0
  232.  
  233. bguierror:      dc.b    'unable to open the bgui.library',10,0
  234.  
  235. wtitle:         dc.b    'Font Preferences',0
  236. header:         ISEQ_C
  237.                 dc.b    'Selected Fonts',0
  238. lefttext:       ISEQ_R
  239.                 dc.b    'Workbench Icon Text:',10
  240.                 dc.b    'System Default Text:',10
  241.                 dc.b    'Screen Text:',0
  242. righttext:      dc.b    'topaz 8',10,'topaz 8',10,'topaz 8',0
  243. wb:             dc.b    'Select Workbench Icon Text...',0
  244. sd:             dc.b    'Select System Default Text...',0
  245. ss:             dc.b    'Select Screen Text...',0
  246. save:           dc.b    'Save',0
  247. use:            dc.b    'Use',0
  248. cancel:         dc.b    'Cancel',0
  249.  
  250.                 ;
  251.                 ;       Library base storage
  252.                 ;
  253. dosbase:        dc.l    0
  254. intuibase:      dc.l    0
  255. bguibase:       dc.l    0
  256.  
  257.                 ;
  258.                 ;       Window signal mask and object pointer.
  259.                 ;
  260. winsig:         dc.l    0
  261. WO_Window:      dc.l    0
  262.